import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.HashSet;

import java.util.Iterator;
/**
*This is student information class, it extends the calculation class which calculate the average of marks.
*this class just add the additional information of the student.
* 
*/
class StudInfo extends Calculation
{
	String studName,studAddr,studId;
	int studAge;
	
	public StudInfo(){
		EncapsulationTest encapsulation1 = new EncapsulationTest("Datta","dsk123","pune",24);
		EncapsulationTest encapsulation2 = new EncapsulationTest("Datta","rohan123","Nashik",24);
		EncapsulationTest encapsulation3 = new EncapsulationTest();

		/**
		* comparator() method which is compaire the two object
		*/
		if(encapsulation1.compare(encapsulation1,encapsulation2)==1){
			System.out.println("******************************************************");
			System.out.println("The student information is equal");
		}else{
			System.out.println("******************************************************"); 
			System.out.println("The student information is not equal");
		}
		
		/**
		*Equals() method to test the equality of two object
		*/
		if(encapsulation1.equals(encapsulation2)){
			System.out.println("******************************************************"); 
			System.out.println("The object are  equal by using equals()");
		}else{
			System.out.println("******************************************************"); 
			System.out.println("The object are  not equal  by using equals()");
		}

		/**
		*HashCode method to calculate the hash code
		*/
		System.out.println("The Hashcode is:"+encapsulation1.hashCode());

				
                /**
		* Another map which is use in putAll method to insert the all entry at a time
		*/
                Map<Object,String> student=new HashMap<Object,String>();
			student.put(new Integer(1), "Amit");
			student.put(new Integer(2), "Shashank");
			student.put(new Integer(3), "Rahul");
			student.put(new Integer(4), "Deepika");

			/**
			*Creat object on DattaMap class
			*/
			DattaMap dattaMap=new DattaMap();
		
			/*
			*The following code uses the put() method of the DattaMap class
			*/
                        dattaMap.put(4,encapsulation1.getName());
                        dattaMap.put(2,encapsulation1.getAddr());
                        dattaMap.put(3,""+encapsulation1.getAge());
                        dattaMap.put(1,encapsulation1.getIdNum());
           	
			
			/**
			*The get() method of the DattaMap class which print the information from the class
			*/
			System.out.println("");
			System.out.println("Corosponding value is: "+dattaMap.get(1));
                

			/**
			*The putAll method of the DattaMap
			*/
			dattaMap.putAll(student);

			/**
			*Viewing the data entered by using the putAll() method of DattaMap class
			*/
			System.out.println("");
			System.out.println("************The value of given key is :"+dattaMap.get(new Integer(4)));


			
		
		      /**
			*Check whether the Map is empty or not 	
			*/
                      if(dattaMap.isEmpty()==true){
				System.out.println("");
				System.out.println("The map is empty");
			}else{
				System.out.println("");
				System.out.println("The map is not empty");
			}

			/*
			*To get the size of the Map
			*/
			System.out.println("");
			System.out.println("The map Size is: "+dattaMap.size());

			/**
			*containsKey() method of DattaMap which will check whether the given key is in the map or not 
			*/
			if(dattaMap.containsKey(new Integer(7))==true)
			{
				System.out.println("");
				System.out.println("The map contain the given key");
			}else {
				System.out.println("");
				System.out.println("The map does not contain the given key");
			}  


			/**
			*containsValue() method of DattaMap which will check whether the given value is in the map or not 
			*/
			if(dattaMap.containsValue(new String("Datta"))==true)
			{
				System.out.println("");
				System.out.println("The map contain the given value");
			}else {
				System.out.println("");
				System.out.println("The map does not contain the given value");
			}  


			/**
			*keySet() method is view the keys contained in this map
			*/
			HashSet <String> hashSet = new HashSet <String>();
			hashSet.addAll(dattaMap.keySet());
			Iterator iterator;
			iterator = hashSet.iterator();     
			System.out.println("");
			System.out.print("Set of Keys in the given map:  ");
		        while (iterator.hasNext()){ 
				      System.out.print(iterator.next() + "    ");  
			    }




			/**
			*remove() of DattaMap which remove the key from this hash table if it present
			*/
			dattaMap.remove(new Integer(3));
			System.out.println("");
			System.out.println("after removing value of key is :"+dattaMap.get(new Integer(3)));


			/**
			*clear() method of DattaMap which clear the value from the map
			*/
			dattaMap.clear();
			System.out.println("");
		      	System.out.println("after clear the value is: "+dattaMap.get(new Integer(2)));        

		/**
		*Placing the values by using the constructor
		*/
		studName=encapsulation1.getName();
		studAddr= encapsulation1.getAddr();
		studAge=encapsulation1.getAge();
		studId=encapsulation1.getIdNum();

		printInfo(m1,m2,m3,avg);//base class method
		printInfo(studName,studAddr,studId,studAge);
		
	}

	
	void printInfo(String name,String addr,String id,int age){
		System.out.println("*************  Student Extra Information ***********");
		System.out.println("Student Name : " + name);
        	System.out.println("Student Age : "+ age);
		System.out.println("Student Adress : "+ addr);
        	System.out.println("Student Id Number is : "+id );
		System.out.println("**************************************************");
	}


}

